﻿using System;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Mvc.RazorTools.FontAwesome.Tests
{
	[TestClass]
	public class FontAwesomeIconExtensionsTests
	{
		[TestMethod]
		[TestCategory("FontAwesomeIconExtensionsTests")]
		public void CustomizeTest()
		{
			FontAwesomeIcon icon = FontAwesomeIconSet.Star.Customize(new string[] { "value1", "value2", "value3" });

			// ***
			// *** There will be 5 attributes since the class adds 2
			// ***
			Assert.AreEqual(5, icon.ClassAttributes.Count());
			Assert.AreEqual(true, icon.ClassAttributes.ContainsKey("value1"));
			Assert.AreEqual(true, icon.ClassAttributes.ContainsKey("value2"));
			Assert.AreEqual(true, icon.ClassAttributes.ContainsKey("value3"));
			Assert.AreEqual("value1", icon.ClassAttributes["value1"]);
			Assert.AreEqual("value2", icon.ClassAttributes["value2"]);
			Assert.AreEqual("value3", icon.ClassAttributes["value3"]);
			Assert.AreEqual("<i class=\"fa fa-star value1 value2 value3\"></i>", icon.Html.ToString());
		}

		[TestMethod]
		[TestCategory("FontAwesomeIconExtensionsTests")]
		[ExpectedException(typeof(ArgumentNullException))]
		public void CustomizeNullIconParamTest()
		{
			FontAwesomeIcon icon1 = null;
			FontAwesomeIcon icon2 = icon1.Customize();
		}

		[TestMethod]
		[TestCategory("FontAwesomeIconExtensionsTests")]
		[ExpectedException(typeof(ArgumentNullException))]
		public void CustomizeNullItemsParamTest()
		{
			FontAwesomeIcon icon2 = FontAwesomeIconSet.Star.Customize(null);
		}

		[TestMethod]
		[TestCategory("FontAwesomeIconExtensionsTests")]
		public void Large1xTest()
		{
			FontAwesomeIcon icon = FontAwesomeIconSet.Star.Large1x();
			Assert.AreEqual("<i class=\"fa fa-star fa-lg\"></i>", icon.Html.ToString());
		}

		[TestMethod]
		[TestCategory("FontAwesomeIconExtensionsTests")]
		[ExpectedException(typeof(ArgumentNullException))]
		public void Large1xNullIconParamTest()
		{
			FontAwesomeIcon icon1 = null;
			FontAwesomeIcon icon2 = icon1.Large1x();
		}

		[TestMethod]
		[TestCategory("FontAwesomeIconExtensionsTests")]
		public void Large2xTest()
		{
			FontAwesomeIcon icon = FontAwesomeIconSet.Star.Large2x();
			Assert.AreEqual("<i class=\"fa fa-star fa-2x\"></i>", icon.Html.ToString());
		}

		[TestMethod]
		[TestCategory("FontAwesomeIconExtensionsTests")]
		[ExpectedException(typeof(ArgumentNullException))]
		public void Large2xNullIconParamTest()
		{
			FontAwesomeIcon icon1 = null;
			FontAwesomeIcon icon2 = icon1.Large2x();
		}

		[TestMethod]
		[TestCategory("FontAwesomeIconExtensionsTests")]
		public void Large3xTest()
		{
			FontAwesomeIcon icon = FontAwesomeIconSet.Star.Large3x();
			Assert.AreEqual("<i class=\"fa fa-star fa-3x\"></i>", icon.Html.ToString());
		}

		[TestMethod]
		[TestCategory("FontAwesomeIconExtensionsTests")]
		[ExpectedException(typeof(ArgumentNullException))]
		public void Large3xNullIconParamTest()
		{
			FontAwesomeIcon icon1 = null;
			FontAwesomeIcon icon2 = icon1.Large3x();
		}

		[TestMethod]
		[TestCategory("FontAwesomeIconExtensionsTests")]
		public void Large4xTest()
		{
			FontAwesomeIcon icon = FontAwesomeIconSet.Star.Large4x();
			Assert.AreEqual("<i class=\"fa fa-star fa-4x\"></i>", icon.Html.ToString());
		}

		[TestMethod]
		[TestCategory("FontAwesomeIconExtensionsTests")]
		[ExpectedException(typeof(ArgumentNullException))]
		public void Large4xNullIconParamTest()
		{
			FontAwesomeIcon icon1 = null;
			FontAwesomeIcon icon2 = icon1.Large4x();
		}

		[TestMethod]
		[TestCategory("FontAwesomeIconExtensionsTests")]
		public void Large5xTest()
		{
			FontAwesomeIcon icon = FontAwesomeIconSet.Star.Large5x();
			Assert.AreEqual("<i class=\"fa fa-star fa-5x\"></i>", icon.Html.ToString());
		}

		[TestMethod]
		[TestCategory("FontAwesomeIconExtensionsTests")]
		[ExpectedException(typeof(ArgumentNullException))]
		public void Large5xNullIconParamTest()
		{
			FontAwesomeIcon icon1 = null;
			FontAwesomeIcon icon2 = icon1.Large5x();
		}

		[TestMethod]
		[TestCategory("FontAwesomeIconExtensionsTests")]
		public void FixedWidthTest()
		{
			FontAwesomeIcon icon = FontAwesomeIconSet.Star.FixedWidth();
			Assert.AreEqual("<i class=\"fa fa-star fa-fw\"></i>", icon.Html.ToString());
		}

		[TestMethod]
		[TestCategory("FontAwesomeIconExtensionsTests")]
		[ExpectedException(typeof(ArgumentNullException))]
		public void FixedWidthNullIconParam()
		{
			FontAwesomeIcon icon1 = null;
			FontAwesomeIcon icon2 = icon1.FixedWidth();
		}

		[TestMethod]
		[TestCategory("FontAwesomeIconExtensionsTests")]
		public void ListItemTest()
		{
			FontAwesomeIcon icon = FontAwesomeIconSet.Star.ListItem();
			Assert.AreEqual("<i class=\"fa fa-star fa-li\"></i>", icon.Html.ToString());
		}

		[TestMethod]
		[TestCategory("FontAwesomeIconExtensionsTests")]
		[ExpectedException(typeof(ArgumentNullException))]
		public void ListNullIconParamTest()
		{
			FontAwesomeIcon icon1 = null;
			FontAwesomeIcon icon2 = icon1.ListItem();
		}

		[TestMethod]
		[TestCategory("FontAwesomeIconExtensionsTests")]
		public void BorderTest()
		{
			FontAwesomeIcon icon = FontAwesomeIconSet.Star.Border();
			Assert.AreEqual("<i class=\"fa fa-star fa-border\"></i>", icon.Html.ToString());
		}

		[TestMethod]
		[TestCategory("FontAwesomeIconExtensionsTests")]
		[ExpectedException(typeof(ArgumentNullException))]
		public void BorderNullIconParamTest()
		{
			FontAwesomeIcon icon1 = null;
			FontAwesomeIcon icon2 = icon1.Border();
		}

		[TestMethod]
		[TestCategory("FontAwesomeIconExtensionsTests")]
		public void PullRightTest()
		{
			FontAwesomeIcon icon = FontAwesomeIconSet.Star.PullRight();
			Assert.AreEqual("<i class=\"fa fa-star pull-right\"></i>", icon.Html.ToString());
		}

		[TestMethod]
		[TestCategory("FontAwesomeIconExtensionsTests")]
		[ExpectedException(typeof(ArgumentNullException))]
		public void PullRightNullIconParamTest()
		{
			FontAwesomeIcon icon1 = null;
			FontAwesomeIcon icon2 = icon1.PullRight();
		}

		[TestMethod]
		[TestCategory("FontAwesomeIconExtensionsTests")]
		public void PullLeftTest()
		{
			FontAwesomeIcon icon = FontAwesomeIconSet.Star.PullLeft();
			Assert.AreEqual("<i class=\"fa fa-star pull-left\"></i>", icon.Html.ToString());
		}

		[TestMethod]
		[TestCategory("FontAwesomeIconExtensionsTests")]
		[ExpectedException(typeof(ArgumentNullException))]
		public void PullLeftNullIconParamTest()
		{
			FontAwesomeIcon icon1 = null;
			FontAwesomeIcon icon2 = icon1.PullLeft();
		}

		[TestMethod]
		[TestCategory("FontAwesomeIconExtensionsTests")]
		public void SpinTest()
		{
			FontAwesomeIcon icon = FontAwesomeIconSet.Star.Spin();
			Assert.AreEqual("<i class=\"fa fa-star fa-spin\"></i>", icon.Html.ToString());
		}

		[TestMethod]
		[TestCategory("FontAwesomeIconExtensionsTests")]
		[ExpectedException(typeof(ArgumentNullException))]
		public void SpinNullIconParamTest()
		{
			FontAwesomeIcon icon1 = null;
			FontAwesomeIcon icon2 = icon1.Spin();
		}

		[TestMethod]
		[TestCategory("FontAwesomeIconExtensionsTests")]
		public void Rotate90Test()
		{
			FontAwesomeIcon icon = FontAwesomeIconSet.Star.Rotate90();
			Assert.AreEqual("<i class=\"fa fa-star fa-rotate-90\"></i>", icon.Html.ToString());
		}

		[TestMethod]
		[TestCategory("FontAwesomeIconExtensionsTests")]
		[ExpectedException(typeof(ArgumentNullException))]
		public void Rotate90NullIconParamTest()
		{
			FontAwesomeIcon icon1 = null;
			FontAwesomeIcon icon2 = icon1.Rotate90();
		}

		[TestMethod]
		[TestCategory("FontAwesomeIconExtensionsTests")]
		public void Rotate180Test()
		{
			FontAwesomeIcon icon = FontAwesomeIconSet.Star.Rotate180();
			Assert.AreEqual("<i class=\"fa fa-star fa-rotate-180\"></i>", icon.Html.ToString());
		}

		[TestMethod]
		[TestCategory("FontAwesomeIconExtensionsTests")]
		[ExpectedException(typeof(ArgumentNullException))]
		public void Rotate180NullIconParamTest()
		{
			FontAwesomeIcon icon1 = null;
			FontAwesomeIcon icon2 = icon1.Rotate180();
		}

		[TestMethod]
		[TestCategory("FontAwesomeIconExtensionsTests")]
		public void Rotate270Test()
		{
			FontAwesomeIcon icon = FontAwesomeIconSet.Star.Rotate270();
			Assert.AreEqual("<i class=\"fa fa-star fa-rotate-270\"></i>", icon.Html.ToString());
		}

		[TestMethod]
		[TestCategory("FontAwesomeIconExtensionsTests")]
		[ExpectedException(typeof(ArgumentNullException))]
		public void Rotate270NullIconParamTest()
		{
			FontAwesomeIcon icon1 = null;
			FontAwesomeIcon icon2 = icon1.Rotate270();
		}

		[TestMethod]
		[TestCategory("FontAwesomeIconExtensionsTests")]
		public void FlipHorizontalTest()
		{
			FontAwesomeIcon icon = FontAwesomeIconSet.Star.FlipHorizontal();
			Assert.AreEqual("<i class=\"fa fa-star fa-flip-horizontal\"></i>", icon.Html.ToString());
		}

		[TestMethod]
		[TestCategory("FontAwesomeIconExtensionsTests")]
		[ExpectedException(typeof(ArgumentNullException))]
		public void FlipHorizontalNullIconParamTest()
		{
			FontAwesomeIcon icon1 = null;
			FontAwesomeIcon icon2 = icon1.FlipHorizontal();
		}

		[TestMethod]
		[TestCategory("FontAwesomeIconExtensionsTests")]
		public void FlipVerticalTest()
		{
			FontAwesomeIcon icon = FontAwesomeIconSet.Star.FlipVertical();
			Assert.AreEqual("<i class=\"fa fa-star fa-flip-vertical\"></i>", icon.Html.ToString());
		}

		[TestMethod]
		[TestCategory("FontAwesomeIconExtensionsTests")]
		[ExpectedException(typeof(ArgumentNullException))]
		public void FlipVerticalNullIconParamTest()
		{
			FontAwesomeIcon icon1 = null;
			FontAwesomeIcon icon2 = icon1.FlipVertical();
		}

		[TestMethod]
		[TestCategory("FontAwesomeIconExtensionsTests")]
		public void InverseTest()
		{
			FontAwesomeIcon icon = FontAwesomeIconSet.Star.Inverse();
			Assert.AreEqual("<i class=\"fa fa-star fa-inverse\"></i>", icon.Html.ToString());
		}

		[TestMethod]
		[TestCategory("FontAwesomeIconExtensionsTests")]
		[ExpectedException(typeof(ArgumentNullException))]
		public void InverseNullIconParamTest()
		{
			FontAwesomeIcon icon1 = null;
			FontAwesomeIcon icon2 = icon1.Inverse();
		}

		[TestMethod]
		[TestCategory("FontAwesomeIconExtensionsTests")]
		public void Stack1xTest()
		{
			FontAwesomeIcon icon = FontAwesomeIconSet.Star.Stack1x();
			Assert.AreEqual("<i class=\"fa fa-star fa-stack-1x\"></i>", icon.Html.ToString());
		}

		[TestMethod]
		[TestCategory("FontAwesomeIconExtensionsTests")]
		[ExpectedException(typeof(ArgumentNullException))]
		public void Stack1xNullIconParamTest()
		{
			FontAwesomeIcon icon1 = null;
			FontAwesomeIcon icon2 = icon1.Stack1x();
		}

		[TestMethod]
		[TestCategory("FontAwesomeIconExtensionsTests")]
		public void Stack2xTest()
		{
			FontAwesomeIcon icon = FontAwesomeIconSet.Star.Stack2x();
			Assert.AreEqual("<i class=\"fa fa-star fa-stack-2x\"></i>", icon.Html.ToString());
		}

		[TestMethod]
		[TestCategory("FontAwesomeIconExtensionsTests")]
		[ExpectedException(typeof(ArgumentNullException))]
		public void Stack2xNullIconParamTest()
		{
			FontAwesomeIcon icon1 = null;
			FontAwesomeIcon icon2 = icon1.Stack2x();
		}

		[TestMethod]
		[TestCategory("FontAwesomeIconExtensionsTests")]
		public void StackTest1()
		{
			FontAwesomeIcon[] icons = new FontAwesomeIcon[] { FontAwesomeIconSet.SquareO, FontAwesomeIconSet.Twitter };
			FontAwesomeStack stack = icons.Stack();

			Assert.AreEqual("<span class=\"fa-stack\"><i class=\"fa fa-square-o fa-stack-1x\"></i><i class=\"fa fa-twitter fa-stack-1x\"></i></span>", stack.Html.ToString());
		}

		[TestMethod]
		[TestCategory("FontAwesomeIconExtensionsTests")]
		public void StackTest2()
		{
			FontAwesomeIcon[] icons = new FontAwesomeIcon[] { FontAwesomeIconSet.SquareO.Stack2x(), FontAwesomeIconSet.Twitter };
			FontAwesomeStack stack = icons.Stack();

			Assert.AreEqual("<span class=\"fa-stack\"><i class=\"fa fa-square-o fa-stack-2x\"></i><i class=\"fa fa-twitter fa-stack-1x\"></i></span>", stack.Html.ToString());
		}

		[TestMethod]
		[TestCategory("FontAwesomeIconExtensionsTests")]
		public void StackWithStylesTest1()
		{
			FontAwesomeIcon[] icons = new FontAwesomeIcon[] { FontAwesomeIconSet.SquareO, FontAwesomeIconSet.Twitter };
			FontAwesomeStack stack = icons.Stack("value1", "value2", "value3");

			Assert.AreEqual("<span class=\"fa-stack value1 value2 value3\"><i class=\"fa fa-square-o fa-stack-1x\"></i><i class=\"fa fa-twitter fa-stack-1x\"></i></span>", stack.Html.ToString());
		}

		[TestMethod]
		[TestCategory("FontAwesomeIconExtensionsTests")]
		public void StackWithStylesTest2()
		{
			FontAwesomeIcon[] icons = new FontAwesomeIcon[] { FontAwesomeIconSet.SquareO.Stack2x(), FontAwesomeIconSet.Twitter };
			FontAwesomeStack stack = icons.Stack("value1", "value2", "value3");

			Assert.AreEqual("<span class=\"fa-stack value1 value2 value3\"><i class=\"fa fa-square-o fa-stack-2x\"></i><i class=\"fa fa-twitter fa-stack-1x\"></i></span>", stack.Html.ToString());
		}

		[TestMethod]
		[TestCategory("FontAwesomeIconExtensionsTests")]
		public void CssOnlyTest1()
		{
			string css = FontAwesomeIconSet.Check.CssOnly();
			string[] items = css.Split(new char[] { ' ' });
			Assert.AreEqual(true, items.Contains("fa"));
			Assert.AreEqual(true, items.Contains("fa-check"));
		}

		[TestMethod]
		[TestCategory("FontAwesomeIconExtensionsTests")]
		public void CssOnlyTest2()
		{
			string css = FontAwesomeIconSet.Check.Customize("style1").CssOnly();
			string[] items = css.Split(new char[] { ' ' });
			Assert.AreEqual(true, items.Contains("fa"));
			Assert.AreEqual(true, items.Contains("fa-check"));
			Assert.AreEqual(true, items.Contains("style1"));
		}
	}
}
